package domain

import (
	"gluenet/modules/manager/server/domain/aggregate"
	"gluenet/modules/manager/server/infra/prepare"
)

func init() {
	//fmt.Printf("domina init\n")
	prepare.RegisterService(func() {
		domain := NewOrganizeDomain()
		prepare.InjectDependency(func() *Organize {
			return domain
		})
	})
}

func NewOrganizeDomain() *Organize {
	domain := &Organize{}
	prepare.FetchDependency(&domain.InfraTreeFactory)
	return domain
}

type Organize struct {
	InfraTreeFactory *aggregate.InfraTreeFactory
}

func (r *Organize) GetTree() (interface{}, error) {
	return r.InfraTreeFactory.GetTree()
}

func (r *Organize) BuildTree() error {
	return r.InfraTreeFactory.BuildTree()
}

func (r *Organize) CleanTree() error {
	return r.InfraTreeFactory.CleanTree()
}
